<?php


namespace app\home\userBusiness;


use app\adminapi\model\pyg_category;
use app\adminapi\model\pyg_goods;
use think\Exception;

class goodsBusiness
{
    /**
     * 商品详情服务层方法
     * @return array
     * @throws Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    public static function getList(){
        $cate_id = request()->get('cate_id');
        $cateInfo = pyg_category::find($cate_id);
       if (!$cateInfo){
           throw new Exception('商品分类不存在');
       }

        $data = pyg_goods::where('cate_id',$cate_id)->paginate(10);
            return [
              'list' => $data,
              'cateInfo' =>$cateInfo
            ];

    }
}